package com.sen.common.widget;

import org.apache.commons.lang.StringUtils;

/**
 * @author sen
 */
public final class Attributes {

	private Attributes() {
		// empty!
	}
	
	public static String attr(String attr, String value) {
		return attrHtmlFormat(attr, value);
	}

	private static String attrHtmlFormat(String attr, String value) {
		return " " + attr + "='" + value + "'";
	}
	
	public static String attrIfNonblank(String attr, String value) {
		if (StringUtils.isBlank(value)) {
			return StringUtils.EMPTY;
		}
		return attrHtmlFormat(attr, value);
	}
	
	public static Attribute merge(Attribute source, Attribute dest) {
		if (null == dest) {
			return source;
		}
		return dest.merge(source);
	}
}
